// 第二种写法
axios.defaults.baseURL = 'http://ajax-api.itheima.net'
      const render = async()=>{
        const { data: { data: res } } = await axios.get('/api/category/top')
          const arr = res.map((item) => {
            return axios.get(`/api/category/sub?id=${item.id}`)
          })
          const newarr= await Promise.all(arr)
          document.querySelector('.top').innerHTML = newarr
            .map((item) => {
              const {data: {data: { name, children},},} = item
              return `<li>
                    <a href="javascript:;">${name}</a>
                    <ul class="sub">
                      ${children.map((item) => {
                  return `<li>
                            <a href="javascript:;">
                            <span>${item.name}</span>
                            <img src=${item.picture} alt="">
                          </a>
                        </li>`
                }).join('')}
                    </ul>
                  </li>`
            }).join('')
       
      }
      render()